﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using System.IO;
using CrystalDecisions.CrystalReports.Engine;
using Microsoft.Reporting.WinForms;
//using CoreEMS.Entities;
//using CoreEMS.BLL;

namespace CMS_GYM
{
    public partial class uctReportViewer : UserControl
    {
        public string _reportName = string.Empty;
        clsReportTemplatesBUS ReportTemplatesBUS = new clsReportTemplatesBUS();
        
        #region uctReportViewer()
        public uctReportViewer()
        {
            InitializeComponent();
        }
        #endregion

        #region InThongBaoTienSanCauLong(DataTable dtKhachHang1, DataTable dtKhachHang2, String ThangIn)
        public void InThongBaoTienSanCauLong(DataTable dtKhachHang1, DataTable dtKhachHang2, String ThangIn)
        {
            try
            {
                ((CMS_GYM.Interface.frmXemBaoCao)Parent).Text = "Thông báo tiền sân cầu lông";
                Microsoft.Reporting.WinForms.ReportParameter[] para = new Microsoft.Reporting.WinForms.ReportParameter[1];
                para[0] = new Microsoft.Reporting.WinForms.ReportParameter("ThangNam", ThangIn);
                rpv_ReportViewer.Reset();
                clsReportTemplatesDTO rt = ReportTemplatesBUS.GetReportTemplate("ThongBaoTienSan");
                rpv_ReportViewer.LocalReport.LoadReportDefinition(rt.ReportTemplateDefinitionXML);
                rpv_ReportViewer.LocalReport.DataSources.Add(new ReportDataSource("KhachHangTienSan1", dtKhachHang1));
                rpv_ReportViewer.LocalReport.DataSources.Add(new ReportDataSource("KhachHangTienSan2", dtKhachHang2));
                rpv_ReportViewer.LocalReport.SetParameters(para);
                System.Drawing.Printing.PageSettings pg = new System.Drawing.Printing.PageSettings();
                pg.Margins.Top = 10;
                pg.Margins.Bottom = 10;
                pg.Margins.Left = 70;
                pg.Margins.Right = 50;
                pg.Landscape = false;
                pg.PaperSize = new System.Drawing.Printing.PaperSize("A4",827,1169);
                rpv_ReportViewer.SetPageSettings(pg);
                rpv_ReportViewer.RefreshReport();
            }
            catch (Exception ex) { MessageBox.Show(ex.ToString()); }
        }
        #endregion

        #region InBangKetToanCauLong(DataTable dtKetToan, String ThangIn)
        public void InBangKetToanCauLong(DataTable dtKetToan, String ThangIn)
        {
            try
            {
                ((CMS_GYM.Interface.frmXemBaoCao)Parent).Text = "Bảng kết toán cầu lông";
                Microsoft.Reporting.WinForms.ReportParameter[] para = new Microsoft.Reporting.WinForms.ReportParameter[1];
                para[0] = new Microsoft.Reporting.WinForms.ReportParameter("ThangNam", ThangIn);
                rpv_ReportViewer.Reset();
                clsReportTemplatesDTO rt = ReportTemplatesBUS.GetReportTemplate("BangKetToanCauLong");
                rpv_ReportViewer.LocalReport.LoadReportDefinition(rt.ReportTemplateDefinitionXML);
                rpv_ReportViewer.LocalReport.DataSources.Add(new ReportDataSource("dtKetToan", dtKetToan));
                rpv_ReportViewer.LocalReport.SetParameters(para);
                System.Drawing.Printing.PageSettings pg = new System.Drawing.Printing.PageSettings();
                pg.Margins.Top = 10;
                pg.Margins.Bottom = 10;
                pg.Margins.Left = 10;
                pg.Margins.Right = 5;
                pg.Landscape = false;
                pg.PaperSize = new System.Drawing.Printing.PaperSize("A4", 827, 1169);
                rpv_ReportViewer.SetPageSettings(pg);
                rpv_ReportViewer.RefreshReport();
            }
            catch (Exception ex) { MessageBox.Show(ex.ToString()); }
        }
        #endregion

        #region InBaoCaoSoLuongKhachHang(DataTable dt, String ThangIn, string NgayIn)
        public void InBaoCaoSoLuongKhachHang(DataTable dt, String ThangIn, string NgayIn)
        {
            try
            {
                ((CMS_GYM.Interface.frmXemBaoCao)Parent).Text = "Báo cáo";
                Microsoft.Reporting.WinForms.ReportParameter[] para = new Microsoft.Reporting.WinForms.ReportParameter[3];
                para[0] = new Microsoft.Reporting.WinForms.ReportParameter("ThangNam", ThangIn);
                para[1] = new Microsoft.Reporting.WinForms.ReportParameter("TongCong", dt.Rows.Count.ToString());
                para[2] = new Microsoft.Reporting.WinForms.ReportParameter("NgayIn", NgayIn);
                rpv_ReportViewer.Reset();
                clsReportTemplatesDTO rt = ReportTemplatesBUS.GetReportTemplate("BaoCaoSoLuongKhachHang");
                rpv_ReportViewer.LocalReport.LoadReportDefinition(rt.ReportTemplateDefinitionXML);
                rpv_ReportViewer.LocalReport.DataSources.Add(new ReportDataSource("KhachHang", dt));
                rpv_ReportViewer.LocalReport.SetParameters(para);
                System.Drawing.Printing.PageSettings pg = new System.Drawing.Printing.PageSettings();
                pg.Margins.Top = 50;
                pg.Margins.Bottom = 30;
                pg.Margins.Left = 20;
                pg.Margins.Right = 10;
                pg.PaperSize = new System.Drawing.Printing.PaperSize("A4", 827, 1169);
                rpv_ReportViewer.SetPageSettings(pg);
                rpv_ReportViewer.RefreshReport();
            }
            catch (Exception ex) { MessageBox.Show(ex.ToString()); }
        }
        #endregion

        #region InBaoCaoSoLuongKhachHangHuongKhuyenMai(DataTable dt, String ThangIn, string NgayIn)
        public void InBaoCaoSoLuongKhachHangHuongKhuyenMai(DataTable dt, String ThangIn, string NgayIn, string ChuThich)
        {
            try
            {
                ((CMS_GYM.Interface.frmXemBaoCao)Parent).Text = "Báo cáo";
                Microsoft.Reporting.WinForms.ReportParameter[] para = new Microsoft.Reporting.WinForms.ReportParameter[4];
                para[0] = new Microsoft.Reporting.WinForms.ReportParameter("ThangNam", ThangIn);
                para[1] = new Microsoft.Reporting.WinForms.ReportParameter("TongCong", dt.Rows.Count.ToString());
                para[2] = new Microsoft.Reporting.WinForms.ReportParameter("NgayIn", NgayIn);
                para[3] = new Microsoft.Reporting.WinForms.ReportParameter("ChuThich", ChuThich);
                rpv_ReportViewer.Reset();
                clsReportTemplatesDTO rt = ReportTemplatesBUS.GetReportTemplate("BaoCaoSoLuongKhachHangHuongKhuyenMai");
                rpv_ReportViewer.LocalReport.LoadReportDefinition(rt.ReportTemplateDefinitionXML);
                rpv_ReportViewer.LocalReport.DataSources.Add(new ReportDataSource("KhachHangKhuyenMai", dt));
                rpv_ReportViewer.LocalReport.SetParameters(para);
                System.Drawing.Printing.PageSettings pg = new System.Drawing.Printing.PageSettings();
                pg.Margins.Top = 30;
                pg.Margins.Bottom = 30;
                pg.Margins.Left = 30;
                pg.Margins.Right = 20;
                pg.PaperSize = new System.Drawing.Printing.PaperSize("A4", 827, 1169);
                rpv_ReportViewer.SetPageSettings(pg);
                rpv_ReportViewer.RefreshReport();
            }
            catch (Exception ex) { MessageBox.Show(ex.ToString()); }
        }
        #endregion

        #region InBaoCaoSoLuongTheSapHetHan(DataTable dt, String ThangIn, string NgayIn)
        public void InBaoCaoSoLuongTheSapHetHan(DataTable dt, String ThangIn, string NgayIn)
        {
            try
            {
                ((CMS_GYM.Interface.frmXemBaoCao)Parent).Text = "Báo cáo";
                Microsoft.Reporting.WinForms.ReportParameter[] para = new Microsoft.Reporting.WinForms.ReportParameter[3];
                para[0] = new Microsoft.Reporting.WinForms.ReportParameter("ThangNam", ThangIn);
                para[1] = new Microsoft.Reporting.WinForms.ReportParameter("TongCong", dt.Rows.Count.ToString());
                para[2] = new Microsoft.Reporting.WinForms.ReportParameter("NgayIn", NgayIn);
                rpv_ReportViewer.Reset();
                clsReportTemplatesDTO rt = ReportTemplatesBUS.GetReportTemplate("BaoCaoSoLuongTheSapHetHan");
                rpv_ReportViewer.LocalReport.LoadReportDefinition(rt.ReportTemplateDefinitionXML);
                rpv_ReportViewer.LocalReport.DataSources.Add(new ReportDataSource("TheSapHetHan", dt));
                rpv_ReportViewer.LocalReport.SetParameters(para);
                System.Drawing.Printing.PageSettings pg = new System.Drawing.Printing.PageSettings();
                pg.Margins.Top = 50;
                pg.Margins.Bottom = 30;
                pg.Margins.Left = 20;
                pg.Margins.Right = 10;
                pg.PaperSize = new System.Drawing.Printing.PaperSize("A4", 827, 1169);
                rpv_ReportViewer.SetPageSettings(pg);
                rpv_ReportViewer.RefreshReport();
            }
            catch (Exception ex) { MessageBox.Show(ex.ToString()); }
        }
        #endregion

        #region InBaoCaoSoLuongTheDaCapTheoKhachHang(DataTable dt, String ThangIn, string NgayIn)
        public void InBaoCaoSoLuongTheDaCapTheoKhachHang(DataTable dt, String ThangIn, string NgayIn)
        {
            try
            {
                ((CMS_GYM.Interface.frmXemBaoCao)Parent).Text = "Báo cáo";
                Microsoft.Reporting.WinForms.ReportParameter[] para = new Microsoft.Reporting.WinForms.ReportParameter[3];
                para[0] = new Microsoft.Reporting.WinForms.ReportParameter("ThangNam", ThangIn);
                para[1] = new Microsoft.Reporting.WinForms.ReportParameter("TongCong", dt.Rows.Count.ToString());
                para[2] = new Microsoft.Reporting.WinForms.ReportParameter("NgayIn", NgayIn);
                rpv_ReportViewer.Reset();
                clsReportTemplatesDTO rt = ReportTemplatesBUS.GetReportTemplate("BaoCaoSoLuongTheCapTheoKhachHang");
                rpv_ReportViewer.LocalReport.LoadReportDefinition(rt.ReportTemplateDefinitionXML);
                rpv_ReportViewer.LocalReport.DataSources.Add(new ReportDataSource("TheDaCap", dt));
                rpv_ReportViewer.LocalReport.SetParameters(para);
                System.Drawing.Printing.PageSettings pg = new System.Drawing.Printing.PageSettings();
                pg.Margins.Top = 50;
                pg.Margins.Bottom = 30;
                pg.Margins.Left = 20;
                pg.Margins.Right = 10;
                pg.PaperSize = new System.Drawing.Printing.PaperSize("A4", 827, 1169);
                rpv_ReportViewer.SetPageSettings(pg);
                rpv_ReportViewer.RefreshReport();
            }
            catch (Exception ex) { MessageBox.Show(ex.ToString()); }
        }
        #endregion

        #region InBaoCaoSoLuongTheDaCap(DataTable dt, String ThangIn, string NgayIn)
        public void InBaoCaoSoLuongTheDaCap(DataTable dt, String ThangIn, string NgayIn)
        {
            try
            {
                ((CMS_GYM.Interface.frmXemBaoCao)Parent).Text = "Báo cáo";
                Microsoft.Reporting.WinForms.ReportParameter[] para = new Microsoft.Reporting.WinForms.ReportParameter[3];
                para[0] = new Microsoft.Reporting.WinForms.ReportParameter("ThangNam", ThangIn);
                para[1] = new Microsoft.Reporting.WinForms.ReportParameter("TongCong", dt.Rows.Count.ToString());
                para[2] = new Microsoft.Reporting.WinForms.ReportParameter("NgayIn", NgayIn);
                rpv_ReportViewer.Reset();
                clsReportTemplatesDTO rt = ReportTemplatesBUS.GetReportTemplate("BaoCaoSoLuongTheDaCap");
                rpv_ReportViewer.LocalReport.LoadReportDefinition(rt.ReportTemplateDefinitionXML);
                rpv_ReportViewer.LocalReport.DataSources.Add(new ReportDataSource("TheDaCap", dt));
                rpv_ReportViewer.LocalReport.SetParameters(para);
                System.Drawing.Printing.PageSettings pg = new System.Drawing.Printing.PageSettings();
                pg.Margins.Top = 50;
                pg.Margins.Bottom = 30;
                pg.Margins.Left = 20;
                pg.Margins.Right = 10;
                pg.PaperSize = new System.Drawing.Printing.PaperSize("A4", 827, 1169);
                rpv_ReportViewer.SetPageSettings(pg);
                rpv_ReportViewer.RefreshReport();
            }
            catch (Exception ex) { MessageBox.Show(ex.ToString()); }
        }
        #endregion
    }
}
